package com.imooc.COR;

import java.util.Random;

import com.imooc.COR.handler.PriceHandler;
import com.imooc.COR.handler.PriceHandlerFactory;

/**
 * 客户，请求折扣
 * @author Administrator
 *
 */
public class Customer {
	private PriceHandler priceHandler;
	
	public void setPriceHandler(PriceHandler priceHandler) {
		this.priceHandler = priceHandler;
	}

	public void requestDiscount(float discount){
		priceHandler.processDiscount(discount);
	}
	
	public static void main(String[] args) {
		Customer customer = new Customer();
		customer.setPriceHandler(PriceHandlerFactory.createPriceHandler());
		
		Random random=new Random();
		
		for (int i = 1; i <= 100; i++) {
			System.out.println(i+":");
			customer.requestDiscount(random.nextFloat());
			
		}
	}
}
